package com.han.util;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.CharSequenceUtil;

import java.io.File;

public class CGUtil {

	/**
	 * 把表结果的_连接改为驼峰结构 首字母大写
	 * @param tableName
	 * @return
	 */
	public static String getPOJONameByTableName(String tableName) {
		return	CharSequenceUtil.upperFirst(getCamelName(tableName));
	}

	public static String getUpperFirst(String str){
		return	CharSequenceUtil.upperFirst(str);
	}
	
	/**
	 * 把字段改为驼峰结构 首字母小写
	 * @param columnName
	 * @return
	 */
	public static String getCamelName(String columnName) {
		return CharSequenceUtil.toCamelCase(columnName);
	}



	public static void delFile() {
		File file = new File(System.getProperty("user.dir") + CGConstants.java_path);
		if (FileUtil.del(file)) {
			FileUtil.del(CGConstants.MapperXmlLocation);
			FileUtil.del(CGConstants.HtmlLocation);
			FileUtil.mkdir(file);
			FileUtil.mkdir(CGConstants.POJOLocation);
//			FileUtil.mkdir(CGConstants.ServiceLocation);
//			FileUtil.mkdir(CGConstants.ServiceImplLocation);
//			FileUtil.mkdir(CGConstants.ControllerLocation);
//			FileUtil.mkdir(CGConstants.HtmlLocation);
		}
	}

	public static void infoLog(Integer msg){
		if (msg != null) {
			infoLog(msg+"");
		}
	}
	public static void infoLog(String msg){
		System.out.println(msg);
	}
	public static void errorLog(String msg){
		errorLog(msg,null);
	}
	public static void errorLog(String msg,Exception e){
		System.out.println(msg);
		System.out.println(e);
	}

}
